package com.googlecode.gwtbb.client.only.widget.form;

import com.google.gwt.user.client.ui.ChangeListener;

/**
 * @author Abraham Grief
 * @version $Id$
 * @since Dec 21, 2008
 */
public abstract class SingletonFormDialogChangeListener extends FormDialogChangeListener implements ChangeListener {
	SingletonDialogFormStarter formStarter = new SingletonDialogFormStarter() {
		public void restartForm() {
			SingletonFormDialogChangeListener.this.restartForm();
		}

		public FormWidget createForm() {
			return SingletonFormDialogChangeListener.this.createForm();
		}
	};

	protected SingletonFormDialogChangeListener(String flagValue) {
		super(flagValue);
	}

	public FormStarter getFormStarter() {
		return formStarter;
	}

	public void clearForm() {
		getForm().reset();
	}

	/**
	 * Hook for subclasses to override
	 */
	public void reinitForm() {
	}

	public void restartForm() {
		clearForm();
		reinitForm();
	}

	public void startProcess() {
		formStarter.startProcess();
	}
}